package top.yxqz.servletconfig;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Mr.余
 * @date 2022/11/14
 * @package top.yxqz.servletconfig
 */
public class ServletConfigDemo3 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ServletConfig config = getServletConfig();
        String resp_encoding = config.getInitParameter("resp_encoding");
        String req_encoding = config.getInitParameter("req_encoding");
        request.setCharacterEncoding(req_encoding);
        response.setContentType(resp_encoding);
        String configName = config.getInitParameter("002");
        response.getWriter().print("名字："+configName);
    }
}
